package com.example.contentproviderdemo;

import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.widget.SimpleCursorAdapter;
import android.app.Activity;
import android.content.ContentResolver;
import android.database.Cursor;
import android.view.Menu;
import android.widget.ListView;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        ContentResolver cr= getContentResolver();
        Cursor cursor= cr.query(Settings.System.DEFAULT_NOTIFICATION_URI, null, null, null, null);
        startManagingCursor(cursor);
        ListView list= (ListView) findViewById(R.id.list);
        String[] from={Settings.System.NAME, Settings.System.VALUE};
        int[] to={R.id.text1,R.id.text2};
        SimpleCursorAdapter adapter= new SimpleCursorAdapter(this,R.layout.row,cursor,from,to);
        list.setAdapter(adapter);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}
